home *** CD-ROM | disk | FTP | other *** search
/ Transactor / Transactor_09_1986_Transactor_Publishing.d64 / projectile c64 (.txt) < prev    next >
Commodore BASIC  |  2023-02-26  |  788b  |  36 lines

  1. 100 rem* bouncing ball simulation *
  2. 110 :
  3. 120 ymax=237: xmax=327
  4. 130 fv=1.4 :rem forward velocity
  5. 140 uv=100 :rem initial upward velocity
  6. 150 y1=0   :rem y start position
  7. 160 x=10   :rem x start position
  8. 170 g=-32.2:rem gravity in feet/s/s
  9. 180 dc=.9  :rem elasticity of "ball"
  10. 190 t=0    :rem time starts at 0
  11. 200 :
  12. 210 gosub 410 'create sprite shape
  13. 220 :
  14. 230 vic=53248     :rem vic video chip
  15. 240 poke vic+21,1 :rem enable sprite 0
  16. 250 poke 2040,14  :rem sprite shape
  17. 260 sx=vic: sy=vic+1: xhi=vic+16
  18. 270 :
  19. 280 :
  20. 290 rem-- main loop --
  21. 300 x=x+fv
  22. 310 y=y1 + uv*t +.5*g*(t*t)
  23. 320 if y<y1 then y=y1:t=0:uv=uv*dc
  24. 330 poke sx,x and 255:poke xhi,-(x>256)
  25. 340 poke sy,ymax-y
  26. 350 t=t+.2
  27. 360 if x<=xmax then 300
  28. 370 end
  29. 380 :
  30. 390 :
  31. 400 rem** create sprite shape at 896 **
  32. 410 fori=896to959:pokei,0:next
  33. 420 fori=925to935step3:reada:pokei,a:next
  34. 430 data 24,126,126,24
  35. 440 return
  36.